#include <iostream>
#include <vector>
#include <unordered_map>
using namespace std;
class Solution
{
public:
    string decodeMessage(string key, string message)
    {
        unordered_map<char, char> keyMap;
        char c = 'a';
        for (int i = 0; i <= key.size(); i++)
        {
            if (key[i]!=' ' && keyMap.find(key[i]) == keyMap.end())
            {
                keyMap[key[i]] = c;
                c++;
            }
        }
        string ans;
        for (char c : message)
        {
            ans += (c != ' ') ? keyMap[c] : c;
        }
        return ans;
    }
};
int main()
{
    Solution s;
    string key = "the quick brown fox jumps over the lazy dog", message = "vkbs bs t suepuv";
    cout << s.decodeMessage(key, message) << endl;
    system("pause");
    return 0;
}
